<template>
  <van-nav-bar title="首页" />

  <div class="wrap">
    <van-search
      v-model="value"
      placeholder="请输入搜索关键词"
      background="transparent"
      shape="round"
    />
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in bannerList" :key="item">
        <img :src="item" alt="" />
      </van-swipe-item>
    </van-swipe>
  </div>
</template>

<script setup>
import { onMounted, ref } from "vue";
import { bannerApi } from "@/api/api";

const bannerList = ref([]);
const value = ref("");

onMounted(async () => {
  const res = await bannerApi();
  if (res.status === "0") {
    bannerList.value = res.result.list;
  }
});
</script>

<style lang="less" scoped>
.my-swipe .van-swipe-item {
  img {
    width: 100%;
    height: 250px;
  }
}

:deep(.van-swipe__indicator) {
  width: 24px;
  height: 4px;
  border-radius: 0;
}

.wrap {
  position: relative;

  .van-search {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 99;

    :deep(.van-search__content) {
      background-color: rgba(255, 255, 255, 0.4);
    }

    :deep(.van-field__control::placeholder) {
      color: #fff;
    }
  }
}
</style>
